// Copyright (c) 2024, hzmes and contributors
// For license information, please see license.txt

frappe.ui.form.on("Server Config", {
	refresh(frm) {
        if (!frm.is_new()) {
			
			frm.add_custom_button(__('测试连接'), () => {
				frm.call({
					method: 'hzplm.hz_plm.doctype.server_config.server_config.login_validate',
					args: {
						server_url: frm.doc.server_url, 
						acctid: frm.doc.acctid, 
						user_name: frm.doc.user_name, 
						user_password: frm.doc.user_password,
					},
				}).then((r) => {	
					frappe.msgprint(r.message)
					// console.log(r.message)
				})
			})
		}
	},
});
